﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace Vision.Utilities.CMS6UpdateTool
{
    public class SiteFileOperateStepConfigurationElement : NamedConfigurationElement
    {
        #region Const
        const string ActionPropertyName = "action";
        const string OrderPropertyName = "order";
        const string FolderPropertyName = "folder";
        const string TargetPropertyName = "target";
        const string ExcludedFilesPropertyName = "excludedFiles";
        #endregion

        #region Ctors
        public SiteFileOperateStepConfigurationElement()
            : base()
        {
        }
        public SiteFileOperateStepConfigurationElement(string name)
            : base(name)
        {
        }
        #endregion

        #region Properties
        [ConfigurationProperty(ActionPropertyName)]
        public SiteFileOperateAction Action
        {
            get { return (SiteFileOperateAction)this[ActionPropertyName]; }
            set { this[ActionPropertyName] = value; }
        }
        [ConfigurationProperty(OrderPropertyName)]
        public int Order
        {
            get { return (int)this[OrderPropertyName]; }
            set { this[OrderPropertyName] = value; }
        }
        [ConfigurationProperty(FolderPropertyName)]
        public string Folder
        {
            get { return (string)this[FolderPropertyName]; }
            set { this[FolderPropertyName] = value; }
        }
        [ConfigurationProperty(TargetPropertyName)]
        public bool Target
        {
            get { return (bool)this[TargetPropertyName]; }
            set { this[TargetPropertyName] = value; }
        }
        [ConfigurationProperty(ExcludedFilesPropertyName)]
        public string ExcludedFiles
        {
            get { return (string)this[ExcludedFilesPropertyName]; }
            set { this[ExcludedFilesPropertyName] = value; }
        }
        #endregion

        #region CreateOperator
        public SiteFileOperator CreateOperator()
        {
            return new SiteFileOperator(Name, Folder, Target, Action, Order, ExcludedFiles ?? string.Empty);
        }
        #endregion
    }
}